//
//  SCVView.m
//  One
//
//  Created by mac on 16-5-20.
//  Copyright (c) 2016年 mac. All rights reserved.
//

#import "SCVView.h"
#import "ShowViewController.h"
@implementation SCVView
{
    UIScrollView *mySCV;
}
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    
    if (self) {

    }
    
    return self;
}

- (void)tap
{
    NSLog(@"tap");
}

- (id)initWithHpObj:(HPObject *)hpObj
{
    
    self = [super init];
    
    if (self) {
        [self layoutMySCV];
        
        ShowViewController *showV = [[ShowViewController alloc]init];
        if (hpObj) {
         showV.hpObj = hpObj;
        }
        showV.view.frame = CGRectMake(0, 0,WIDTH -20,HEIGHT- 100);
        [mySCV addSubview:showV.view];
    }
    
    return self;
    
}

- (void)layoutMySCV
{
    mySCV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0,WIDTH -20,HEIGHT- 40)];
    mySCV.contentSize = CGSizeMake(WIDTH - 20, HEIGHT + 100);
    mySCV.pagingEnabled = NO;
    mySCV.directionalLockEnabled = YES;
    mySCV.showsVerticalScrollIndicator = NO;
    mySCV.showsHorizontalScrollIndicator = NO;
    mySCV.userInteractionEnabled = YES;
    [self removeMySCVSubview];
    
    [self addSubview:mySCV];
}

- (void)removeMySCVSubview
{
    
    NSArray *subViewArr = [mySCV subviews];
    [subViewArr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [obj removeFromSuperview];
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
